﻿package com.sour
{
	import flash.display.*;
	import flash.text.*;
	import flash.events.*;
	import flash.net.*;
	import flash.utils.*;
	import flash.external.ExternalInterface;	
	
	public class knode extends Sprite
	{
		private var _keanode:XML;
		private var _nodeui;
		private var _father;
		
		public function knode(father:Object,node:XML,limit:int):void
		{
			_father = father;
			_keanode = node;
			_nodeui = new generalnode();
			addChild(_nodeui);

			if(limit == 3)
			{
				_nodeui.gotoAndStop(2);					
			}
			else if(limit == 2)
			{
				if(node.@status == "approved")
				{
					_nodeui.gotoAndStop(3);
				}
				else
				{
					_nodeui.gotoAndStop(5);					
				}
			}
			else
			{
				if(node.@status == "approved")
				{
					_nodeui.gotoAndStop(4);
				}
				else
				{
					_nodeui.gotoAndStop(6);					
				}
			}
					
			_nodeui.addEventListener(MouseEvent.ROLL_OVER, MouseOn);			
			_nodeui.addEventListener(MouseEvent.ROLL_OUT, MouseOut);
			_nodeui.addEventListener(MouseEvent.CLICK, MouseClick);			
		}
		
		public function MouseClick(event:MouseEvent):void
		{
			trace("click id" + _keanode.@id);
			_father.Reload(this);
			if(ExternalInterface.available)
			{
				ExternalInterface.call("redirect","" + _keanode.@id);
			}		
		}		
		
		public function MouseOn(event:MouseEvent):void
		{
			_father.MouseOn(this);
		}
		
		public function MouseOut(event:MouseEvent):void
		{
			_father.MouseOut(this);
		}		
		
		public function get keanode():XML
		{
			return _keanode;
		}
		
	}
}